import 'node-assist'
import CommonUtil from 'js-common-modules/lib/node/utils/CommonUtil'
import BigInteger from 'bigi'
import bitcorejs from 'bitcoinjs-lib'
import CryptUtil from 'js-common-modules/lib/node/utils/CryptUtil'

global['logger'] = console

const config = {
  version: 'mainnet',
  mint: '****'
}


CommonUtil.startAsyncMethod(async () => {
  config['version'] === 'mainnet' && (config['version'] = 'bitcoin')
  const afterSha256 = CryptUtil.sha256(config['mint'])
  const d = BigInteger.fromBuffer(Buffer.from(afterSha256, 'hex'))
  const ecPair = new bitcorejs.ECPair(d, null, {
    compressed: false,
    network: bitcorejs.networks[config['version']]
  })
  logger.error({
    address: ecPair.getAddress(),
    wif: ecPair.toWIF()
  })
})